<?php
    class category_view_controller extends controllerBase
    {
        public function process()
        {
            if(!is_numeric($this->iId))
            {
                return $this->url->getLink('' , true, 'Page not found.');
            }
            $oCategory = $this->database->getObject('SELECT * FROM category WHERE category_id='.(int)$this->iId);
            if(!$oCategory)
            {
                return $this->url->getLink('' , true, 'Page not found.'); 
            }
            $this->set(array('oCategory' => $oCategory));
            $aProducts = $this->database->getListObject('SELECT p.*,c.title AS category_name,images.url AS image_url  FROM product AS p JOIN category AS c ON p.category_id = c.category_id LEFT JOIN images ON p.image_id = images.image_id WHERE c.category_id='.(int)$this->iId);
            $this->set(array('aProducts' => $aProducts));
        }
    }
?>
